package com.atguigu.spzx.cloud.order.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;


//@LoadBalancerClients(value = {
//        @LoadBalancerClient(name = "spzx-cloud-user" , configuration = CustomLoadBalancerConfiguration.class)      // 将负载均衡算法应用到指定的服务提供方中
//})
@Configuration
public class RestTemplateConfiguration {


    //RestTemplate可以进行http的网络请求和调用!
    //是不是微服务项目都可以使用
    //之前是单体项目,他没有用武之地
    @Bean
    @LoadBalanced //添加以后就带了负载均衡
    public RestTemplate restTemplate() {
        return new RestTemplate() ;
    }

}